<div class="main_body">
    <?php echo $this->element('main_menu')?>		
	<div id="main_body_content">
	
	
		<div class="orders form">
		<?php echo $this->Form->create('Order');?>
			<fieldset>
		 		<legend><?php __("Add Order"); ?></legend>
				<?php echo $this->Form->input('numer');?>
				<?php echo $this->Form->input('name',array('size'=>50));?>
		 		<div class="input select required">
		 			
					<label for="OrderSelectCustomerId"><?php __("Select Customer");?></label>
					<div class="customers index scrollable">
						
						<table cellpadding="0" cellspacing="0" class="items">
						<?php
						$i = 0;
						foreach ($customers as $customer):
							$class = null;
							if ($i++ % 2 == 0) {
								$class = ' class="altrow"';
							}
						?>
						<tr<?php echo $class;?>>
							<td>
								<?php //echo $form->radio('customer_id',array($customer['Customer']['id']=>false),array('legend'=>false,'checked'=>((isset($this->data['Order']['customer_id']) && $this->data['Order']['customer_id'] ==  $customer['Customer']['id'])?"checked":"")));?>
								<input type="radio" name="data[Order][customer_id]" id="OrderCustomerId<?php echo $customer['Customer']['id']?>" value="<?php echo $customer['Customer']['id']?>" /> 
							</td>			
							<td><?php echo $customer['Customer']['name']; ?>&nbsp;<br/>
								<?php echo $customer['Customer']['surname']; ?>&nbsp;</td>
							<td><?php echo $customer['Customer']['address1']; ?>&nbsp;<br/>
								<?php echo $customer['Customer']['address2']; ?>&nbsp;</td>
							<td class="actions"><?php echo $customer['Customer']['phone1']; ?>&nbsp;</td>
			
						</tr>
					<?php endforeach; ?>
						</table>
					</div>
				</div>
				<div class="clr"></div>	
						 		
			<?php		
				echo $this->Form->input('type_of_service_id',array('empty'=>''));
				echo $this->Form->input('types_of_spaces_id',array('empty'=>''));
			//	echo $this->Form->input('type_of_performance_id');
				echo $this->Form->input('status_of_implementation',array('options'=>$statusOfImplementation,'empty'=>''));
				echo $this->Form->input('payment_status',array('options'=>$paymentStatus,'empty'=>''));
				echo $this->Form->input('estimated_execution_time');
				echo $this->Form->input('value_of_the_order');
				
			?>
			
				<div class="input select required">
					<label for="OrderSelectEmployeeId"><?php __("Select Employee");?></label>
					<div class="customers index scrollable">
						
						<table cellpadding="0" cellspacing="0" class="items">
						
						<?php						
						$i = 0;
						foreach ($employees as $employee):
							$class = null;
							if ($i++ % 2 == 0) {
								$class = ' class="altrow"';
							}
						?>
						<tr<?php echo $class;?>>
							<td><?php echo $form->checkbox('Employee.'.$employee['Employee']['id'].'.employee_id',array('value'=>$employee['Employee']['id']));?></td>	
							<td><?php echo $form->input('Employee.'.$employee['Employee']['id'].'.percent',array('size'=>2,'label'=>__("proc.",true),'after'=>false)); ?></td>
							<td><?php echo $form->input('Employee.'.$employee['Employee']['id'].'.amount',array('size'=>5,'label'=>__("amount",true),'after'=>false)); ?></td>
							<td><?php echo $employee['Employee']['name']; ?><br/><?php echo $employee['Employee']['surname']; ?></td>
							<td><?php echo $employee['Employee']['address1']; ?><br/>
								<?php echo $employee['Employee']['address2']; ?></td>
							<td class="actions">
								<?php echo $typeOfWorks[$employee['Employee']['type_of_work_id']]; ?><br/>
								<?php echo (array_key_exists($employee['Employee']['type_of_work_2_id'], $typeOfWorks)) ? $typeOfWorks[$employee['Employee']['type_of_work_2_id']] : ""; ?><br/>
								<?php echo (array_key_exists($employee['Employee']['type_of_work_3_id'], $typeOfWorks)) ? $typeOfWorks[$employee['Employee']['type_of_work_3_id']] : ""; ?>
							</td>			
						</tr>
					<?php endforeach; ?>
						</table>
					</div>
				</div>
				<div class="clr"></div>

				
				<div class="orders_cycles index">
				<?php echo $this->Form->input('OrdersCycle.type_of_cycle_id',array('options'=>$typeOfCycles));	?>
				
				<?php 
					echo $javascript->codeBlock("
						$(document).ready(function() {						
							$('#OrdersCycleTypeOfCycleId').change(function () {
					    		var otoci = $(this).attr('value');
					    		switch(otoci){
									case '1':
										//alert($(this).attr('value'));
										$('#repeat_for_month').css('display','block');
										$('#repeat_for_week').css('display','none');									
										$('.added_breaks').remove();																				
										break;
									case '2':
										//alert($(this).attr('value'));
										$('#repeat_for_month').css('display','none');
										$('#repeat_for_week').css('display','block');
										$('.added_breaks').remove();
										break;
									case '3':
										//alert($(this).attr('value'));
										$('#repeat_for_month').css('display','none');
										$('#repeat_for_week').css('display','none');
										$('.added_breaks').remove();
										break;										
									case '4':
										$('#repeat_for_week').css('display','none');
										$('#repeat_for_month').css('display','none');										
										$('.added_breaks').remove();
										break;
									case '5':
										$('#repeat_for_week').css('display','none');
										$('#repeat_for_month').css('display','none');										
										$('.added_breaks').remove();	
										break;										
					    		}											
							});
											
						});
					", $options = array('allowCache'=>true,'safe'=>false,'inline'=>false), false)
				?>
				
				<label for="OrderSelectOrdersCycles"><?php __("Orders Cycles");?></label>
				<table cellpadding="0" cellspacing="0" class="items" id="repeat_for_month">
					<tr>
						<td>1<?php echo $this->Form->checkbox('OrdersCycle_m._1');?></td>
						<td>2<?php echo $this->Form->checkbox('OrdersCycle_m._2');?></td>
						<td>3<?php echo $this->Form->checkbox('OrdersCycle_m._3');?></td>
						<td>4<?php echo $this->Form->checkbox('OrdersCycle_m._4');?></td>
						<td>5<?php echo $this->Form->checkbox('OrdersCycle_m._5');?></td>
						<td>6<?php echo $this->Form->checkbox('OrdersCycle_m._6');?></td>
						<td>7<?php echo $this->Form->checkbox('OrdersCycle_m._7');?></td>
						<td>8<?php echo $this->Form->checkbox('OrdersCycle_m._8');?></td>
						<td>9<?php echo $this->Form->checkbox('OrdersCycle_m._9');?></td>
						<td>10<?php echo $this->Form->checkbox('OrdersCycle_m._10');?></td>
						<td>11<?php echo $this->Form->checkbox('OrdersCycle_m._11');?></td>
						<td>12<?php echo $this->Form->checkbox('OrdersCycle_m._12');?></td>
						<td>13<?php echo $this->Form->checkbox('OrdersCycle_m._13');?></td>
						<td>14<?php echo $this->Form->checkbox('OrdersCycle_m._14');?></td>
						<td>15<?php echo $this->Form->checkbox('OrdersCycle_m._15');?></td>
						<td class="actions">16<?php echo $this->Form->checkbox('OrdersCycle_m._16');?></td>
					</tr>
					<tr>
						<td>17<?php echo $this->Form->checkbox('OrdersCycle_m._17');?></td>
						<td>18<?php echo $this->Form->checkbox('OrdersCycle_m._18');?></td>
						<td>19<?php echo $this->Form->checkbox('OrdersCycle_m._19');?></td>
						<td>20<?php echo $this->Form->checkbox('OrdersCycle_m._20');?></td>
						<td>21<?php echo $this->Form->checkbox('OrdersCycle_m._21');?></td>
						<td>22<?php echo $this->Form->checkbox('OrdersCycle_m._22');?></td>
						<td>23<?php echo $this->Form->checkbox('OrdersCycle_m._23');?></td>
						<td>24<?php echo $this->Form->checkbox('OrdersCycle_m._24');?></td>
						<td>25<?php echo $this->Form->checkbox('OrdersCycle_m._25');?></td>
						<td>26<?php echo $this->Form->checkbox('OrdersCycle_m._26');?></td>
						<td>27<?php echo $this->Form->checkbox('OrdersCycle_m._27');?></td>
						<td>28<?php echo $this->Form->checkbox('OrdersCycle_m._28');?></td>
						<td>29<?php echo $this->Form->checkbox('OrdersCycle_m._29');?></td>
						<td>30<?php echo $this->Form->checkbox('OrdersCycle_m._30');?></td>
						<td>31<?php echo $this->Form->checkbox('OrdersCycle_m._31');?></td>
						<td class="actions">&nbsp;</td>
					</tr>
				</table>
				<table cellpadding="0" cellspacing="0" class="items"  id="repeat_for_week"  style="display: none">
					<tr>
						<td align="center"><?php echo __("Monday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._1');?></td>
						<td align="center"><?php echo __("Tuesday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._2');?></td>
						<td align="center"><?php echo __("Wednesday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._3');?></td>
						<td align="center"><?php echo __("Thursday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._4');?></td>
						<td align="center"><?php echo __("Friday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._5');?></td>
						<td align="center"><?php echo __("Saturday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._6');?></td>
						<td align="center"  class="actions"><?php echo __("Sunday",true)?> <?php echo $this->Form->checkbox('OrdersCycle_w._7');?></td>
					</tr>
				</table>
				<table cellpadding="0" cellspacing="0" class="items"  id="repeat_for_week">
					<tr>
						<td align="left" colspan="2"  class="actions" style="text-align: right;">
							<?php echo __("Repeat every ",true)?>
						</td>
						<td  class="actions">
							<?php echo $this->Form->input('OrdersCycle.repeat',array('size'=>3,'label'=>false,'after'=>false));?>
						</td>
						<td colspan="4"  class="actions" align="left" style="text-align: left;">	
							
						</td>
					</tr>
				</table>
				<div class="clr"></div><br/>
				<?php echo $this->Form->checkbox('OrdersCycle.except_saturdays',array('style'=>'display: inline;'));?>	<?php __("Poza sobotami")?>
				<?php echo $this->Form->checkbox('OrdersCycle.except_sandays',array('style'=>'display: inline;'));?> <?php __("Poza niedzielami")?>		
				<?php 
					echo $javascript->codeBlock("
						$(document).ready(function() {
							$( \"#OrderDateStart\" ).datepicker({showButtonPanel: true, dateFormat: 'mm-dd-yy'});
							$( \"#OrdersCycleDateEnd\" ).datepicker({showButtonPanel: true, dateFormat: 'mm-dd-yy'});
							$( \"#OrdersBreak_DateStart\" ).datepicker({showButtonPanel: true, dateFormat: 'mm-dd-yy'});
							$( \"#OrdersBreak_DateEnd\" ).datepicker({showButtonPanel: true, dateFormat: 'mm-dd-yy'});		
						});
						",$options = array('allowCache'=>true,'safe'=>true,'inline'=>false));
				?>
				<table class="czysta" cellpadding="0" cellspacing="0"  id="subFormAddBreaksForOrderCycle">
					<tr>
						<td>
							<?php __("the duration of the order")?>
						</td>
						<td>
						<?php echo $this->Form->input('Order.date_start',array('type'=>'text','size'=>12)); ?>
						</td>
						<td>
						<?php echo $this->Form->input('OrdersCycle.date_end',array('type'=>'text','size'=>12)); ?>
						</td>
						<td class="actions">&nbsp;</td>
					</tr>
					<tr id="subFormForBreaks">
						<td>
							<?php __("breaks in order")?>
						</td>
						<td>
						<?php echo $this->Form->input('OrdersBreak_.date_start',array('type'=>'text','size'=>12)); ?>
						</td>
						<td>
						<?php echo $this->Form->input('OrdersBreak_.date_end',array('type'=>'text','size'=>12)); ?>
						</td>
						<td class="actions">
							<?php echo $html->image(HOST.'/actions_breaks_add.png',array('onclick'=>'addNewBreakForOrderCycle()'))?>
						</td>
					</tr>					
				</table>
			</div>				
			<?php 
				echo $javascript->codeBlock("
					var id = 0;
					function addNewBreakForOrderCycle(){
						//id = $('.added_breaks').size();
						id = id + 1;
						var _html_tr = '<tr class=\"added_breaks\" id=\"break_'+id+'\">';
							_html_tr += '<td>".__("interval",true)."</td>';
							_html_tr += '<td>'+$('#OrdersBreak_DateStart').attr('value')+'<input type=\"hidden\" name=\"data[OrdersBreak]['+id+'][date_start]\" value=\"'+$('#OrdersBreak_DateStart').attr('value')+'\"/></td>';
							_html_tr += '<td>'+$('#OrdersBreak_DateEnd').attr('value')+'<input type=\"hidden\" name=\"data[OrdersBreak]['+id+'][date_end]\" value=\"'+$('#OrdersBreak_DateEnd').attr('value')+'\"/></td>';
							_html_tr += '<td class=\"actions\"><img src=\"/img/21w.cleaning/actions_breaks_delete.png\" alt=\"\" onclick=\"deleteBreakForOrderCycle('+id+')\"/></td>';
							_html_tr += '</tr>';
					
						$('#subFormAddBreaksForOrderCycle').append(_html_tr);
						$('#OrdersBreak_DateStart').attr('value','');
						$('#OrdersBreak_DateEnd').attr('value','');
					}
					
					function deleteBreakForOrderCycle(id){
						$('#break_'+id).remove();
					}
				", $options = array('allowCache'=>true,'safe'=>false,'inline'=>false), false)
			?>	
			
			<?php echo $this->Form->input('Order.note_manager'); ?>
			<?php echo $this->Form->input('Order.note_customer'); ?>
			<?php echo $this->Form->input('Order.note_employee'); ?>
			
			</fieldset>
		<?php echo $this->Form->end(__("Submit", true));?>
		</div>

		<div class="clr"></div>	
	</div>			
	<?php echo $this->element('languages')?>	
	<div class="clr"></div>
</div>	
<div class="clr"></div>	
<div class="main_action">
	<div class="main_action_content">
	
		<div class="actions">
			<h3><?php __("Actions"); ?></h3>
			<ul>		
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_orders_list.png'), array('controller' => 'orders', 'action' => 'index'),array('escape'=>false,'title'=>__("List Orders", true))); ?><div class="clr"></div>	<?php echo __("List Orders", true)?> </li>				
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_customers.png'), array('controller' => 'customers','action' => 'index'),array('escape'=>false,'title'=>__("List Customers",true)));?><div class="clr"></div>	<?php echo __("List Customers",true)?></li>				
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_services.png'), array('controller' => 'type_of_services', 'action' => 'index'),array('escape'=>false,'title'=>__("List Type Of Services",true))); ?><div class="clr"></div> <?php echo __("List Type Of Services",true)?> </li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_services_add.png'), array('controller' => 'type_of_services', 'action' => 'add'),array('escape'=>false,'title'=>__("New Type Of Service", true))); ?> <div class="clr"></div>	<?php echo __("New Type Of Service", true)?> </li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_spaces.png'), array('controller' => 'types_of_spaces', 'action' => 'index'),array('escape'=>false,'title'=>__("List Types Of Spaces", true))); ?> <div class="clr"></div>	<?php echo __("List Types Of Spaces", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_spaces_add.png'), array('controller' => 'types_of_spaces', 'action' => 'add'),array('escape'=>false,'title'=>__("New Types Of Spaces", true))); ?> <div class="clr"></div>	<?php echo __("New Types Of Spaces", true)?></li>
				<li><?php echo $this->Html->link($html->image(HOST.'/actions_employees.png'), array('controller' => 'employees', 'action' => 'index'),array('escape'=>false,'title'=>__("List Employees", true))); ?> <div class="clr"></div> <?php echo __("List Employees", true)?></li>
				
			</ul>
		</div>	
		<div class="clr"></div>
	</div>		
</div>		
